package customer9_1_2_7;

public class Invoice {
	private int ID;
	private Customer customer;
	private double amount;

	public Invoice(int iD, Customer customer, double amount) {
		super();
		ID = iD;
		this.customer = customer;
		this.amount = amount;
	}

	public int getID() {
		return ID;
	}

	public void setID(int iD) {
		ID = iD;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public String getCustomerName() {
		return customer.getName();
	}

	public double getAmountAfterDiscount() {
		return amount * customer.getDiscount() / 10;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return Integer.hashCode(ID) + customer.hashCode() + Double.hashCode(amount);
	}

	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if(!(obj instanceof Invoice))
			return false;
		Invoice invoice = (Invoice) obj;
		return this.ID == invoice.ID && this.customer == invoice.customer && this.amount == invoice.amount;
	}

	@Override
	public String toString() {
		return "Invoice [ID=" + ID + ", customer=" + customer + ", amount=" + amount + "]";
	}
	
}
